; *** Jungle (Chess)
; *** Copyright 1998-2002 Zillions Development
; v.2.0

; You need to purchase Zillions of Games to load this rules file
; Visit the Zillions web site at http://www.zillions-of-games.com
(translate
      ("White""白方") ("Black" "黑方") ("Tiger""虎") ("Elephant""象")
      ("Cat""猫") ("Wolf""狼") ("Panther""豹")
      ("Dog""狗") ("Rat""鼠") ("Lion""狮")
      ("Jungle" "斗兽棋")("Jungle Variant" "斗兽棋二")
)
(define Rat-Step (
	$1
	(verify not-friend?)
	(verify (not-in-zone? Own-Den))
	(if (or empty? (in-zone? Trap))
		add
	 else ;enemy
		(verify (or (piece? Rat)
		            (and (piece? Elephant) (not-in-zone? water (opposite $1)) )
				)
		)
		add
	)
))

(define Cat-Step (
	$1
	(verify not-friend?)
	(verify (not-in-zone? water)) 
	(verify (not-in-zone? Own-Den)) 
	(if (or empty? (in-zone? Trap))
		add
	 else ;enemy
		(verify (or (piece? Rat) (piece? Cat)))
		add
	)
))

(define Wolf-Step (
	$1
	(verify not-friend?)
	(verify (not-in-zone? water)) 
	(verify (not-in-zone? Own-Den)) 
	(if (or empty? (in-zone? Trap))
		add
	 else ;enemy
		(verify (or (piece? Rat) (piece? Cat) (piece? Wolf)))
		add
	)
))

(define Dog-Step (
	$1
	(verify not-friend?)
	(verify (not-in-zone? water)) 
	(verify (not-in-zone? Own-Den)) 
	(if (or empty? (in-zone? Trap))
		add
	 else ;enemy
		(verify (not-piece? Elephant)) 
		(verify (not-piece? Lion))
		(verify (not-piece? Tiger)) 
		(verify (not-piece? Panther))
		add
	)
))

(define Panther-Step (
	$1
	(verify not-friend?)
	(verify (not-in-zone? water)) 
	(verify (not-in-zone? Own-Den)) 
	(if (or empty? (in-zone? Trap))
		add
	 else ;enemy
		(verify (not-piece? Elephant)) 
		(verify (not-piece? Lion))
		(verify (not-piece? Tiger)) 
		add
	)
))

(define Tiger-Step (
	$1
	(while (in-zone? water) (verify empty?) $1) 
	(verify not-friend?)
	(verify (not-in-zone? Own-Den)) 
	(if (or empty? (in-zone? Trap))
		add
	 else ;enemy
		(verify (not-piece? Elephant)) 
		(verify (not-piece? Lion))
		add
	)
))

(define Lion-Step (
	$1
	(while (in-zone? water) (verify empty?) $1) 
	(verify not-friend?)
	(verify (not-in-zone? Own-Den)) 
	(if (or empty? (in-zone? Trap))
		add
	 else ;enemy
		(verify (not-piece? Elephant)) 
		add
	)
))

(define Elephant-Step2 (
	$1
	(verify not-friend?)
	(verify (not-in-zone? water)) 
	(verify (not-in-zone? Own-Den)) 
	add
))
(define Elephant-Step (
	$1
	(verify not-friend?)
	(verify (not-in-zone? water)) 
	(verify (not-in-zone? Own-Den)) 
	(if (or empty? (in-zone? Trap))
		add
	 else ;enemy
		(verify (not-piece? Rat)) 
		add
	)
))

(define Board-Definitions
  (image "images\Jungle\jungle.bmp")
  (grid
     (start-rectangle 5 3 62 62)
     (dimensions
         ("a/b/c/d/e/f/g" (61 0)) ; files
         ("9/8/7/6/5/4/3/2/1" (0 61)) ; ranks
     )
     (directions (n 0 -1) (e 1 0) (s 0 1) (w -1 0))
  )
  (zone
     (name Den)
     (players White)
     (positions d9)
  )
  (zone
     (name Den)
     (players Black)
     (positions d1)
  )
  (zone
     (name Own-Den)
     (players White)
     (positions d1)
  )
  (zone
     (name Own-Den)
     (players Black)
     (positions d9)
  )
  (zone
     (name Trap)
     (players White)
     (positions c1 e1 d2)
  )
  (zone
     (name Trap)
     (players Black)
     (positions c9 e9 d8)
  )
  (zone
     (name water)
     (players Black White)
     (positions b4 b5 b6 c4 c5 c6 e4 e5 e6 f4 f5 f6)
  )
)

(game
   (title "Jungle")
   (description "进入对方兽穴获胜。\斗兽棋吃法如下：象>狮>虎>豹>狗>狼>猫>鼠。同种动物相遇可以互吃，鼠能吃象。
\鼠可以进入水中，但入水时无法吃陆上的象。狮虎可以跳过河流，但不能越过水中的鼠。\
任何动物走进敌方陷阱则失去攻击力，可以被任何对方动物吃。陷阱可以自由出入。\
注意：第二个版本，象可以吃老鼠。")
   (history "The Jungle Game is an old Chinese called `Shou Dou Qi`.  It is used as a
     stepping stone in teaching XiangQi (Chinese Chess).")
   (strategy "You can use your Rat in the water to help block the Elephant.  Keep your Den
     safe by posting guards near it, remembering that the only way to invade a Den is
     through a Trap and that any animal may kill another animal in a Trap.")
   (option "prevent flipping" 2)
   (opening-sound "Audio\\Jungle.wav")
   (move-sound "Audio\\JungleQuiet.wav")
   (capture-sound "Audio\\Jungle3Notes.wav")
   (release-sound "Audio\\JungleCrash.wav")
   (win-sound "Audio\\Jungle_AC.wav")
   (loss-sound "Audio\\Jungle_AC.wav")
   (players White Black)
   (turn-order White Black)
   (board (Board-Definitions))

   (board-setup
      (White
         (Tiger a1)
         (Elephant a3)
         (Cat b2)
         (Wolf c3)
         (Panther e3)
         (Dog f2)
         (Rat g3)
         (Lion g1)
      )
      (Black
         (Tiger g9)
         (Elephant g7)
         (Cat f8)
         (Wolf e7)
         (Panther c7)
         (Dog b8)
         (Rat a7)
         (Lion a9)
      )
   )

   (piece
      (name Rat)
      (description "鼠\可入水，但水里不能吃岸上的其他子。吃鼠或象。")
	  (help "鼠：可入水，可吃象")
      (image White "images\Jungle\WRat.bmp" Black "images\Jungle\BRat.bmp")
      (moves
         (Rat-Step n)
         (Rat-Step e)
         (Rat-Step s)
         (Rat-Step w)
      )
   )

   (piece
      (name Cat)
      (description "猫\吃鼠、猫")
	  (help "猫")
      (image White "images\Jungle\WCat.bmp" Black "images\Jungle\BCat.bmp")
      (moves
         (Cat-Step n)
         (Cat-Step e)
         (Cat-Step s)
         (Cat-Step w)
      )
   )

   (piece
      (name Wolf)
      (description "狼\吃鼠、猫、狼")
	  (help "狼")
      (image White "images\Jungle\WWolf.bmp" Black "images\Jungle\BWolf.bmp")
      (moves
         (Wolf-Step n)
         (Wolf-Step e)
         (Wolf-Step s)
         (Wolf-Step w)
      )
   )

   (piece
      (name Dog)
      (description "狗\吃鼠、猫、狼、狗")
	  (help "狗")
      (image White "images\Jungle\WDog.bmp" Black "images\Jungle\BDog.bmp")
      (moves
         (Dog-Step n)
         (Dog-Step e)
         (Dog-Step s)
         (Dog-Step w)
      )
   )

   (piece
      (name Panther)
      (description "豹\吃象、狮、虎以外的子。")
	  (help "豹")
      (image White "images\Jungle\WPanther.bmp" Black "images\Jungle\BPanther.bmp")
      (moves
         (Panther-Step n)
         (Panther-Step e)
         (Panther-Step s)
         (Panther-Step w)
      )
   )

   (piece
      (name Tiger)
      (description "虎\虎可以跳河。吃象、狮以外的子。")
	  (help "虎：可跳河")
      (image White "images\Jungle\WTiger.bmp" Black "images\Jungle\BTiger.bmp")
      (moves
         (Tiger-Step n)
         (Tiger-Step e)
         (Tiger-Step s)
         (Tiger-Step w)
      )
   )

   (piece
      (name Lion)
      (description "狮子\狮子可以跳河。吃象以外的其他子。")
      (help "狮子：可跳河")
      (image White "images\Jungle\WLion.bmp" Black "images\Jungle\BLion.bmp")
      (moves
         (Lion-Step n)
         (Lion-Step e)
         (Lion-Step s)
         (Lion-Step w)
      )
   )

   (piece
      (name Elephant)
      (description "象\不可入水，吃除老鼠外所有子。只能被老鼠或象吃。")
      (help "象：不能吃老鼠")
      (image White "images\Jungle\WElephant.bmp" Black "images\Jungle\BElephant.bmp")
      (moves
         (Elephant-Step n)
         (Elephant-Step e)
         (Elephant-Step s)
         (Elephant-Step w)
      )
   )

   (win-condition (Black)  (absolute-config Elephant (d1)))
   (win-condition (Black)  (absolute-config Tiger (d1)))
   (win-condition (Black)  (absolute-config Lion (d1)))
   (win-condition (Black)  (absolute-config Panther (d1)))
   (win-condition (Black)  (absolute-config Dog (d1)))
   (win-condition (Black)  (absolute-config Wolf (d1)))
   (win-condition (Black)  (absolute-config Cat (d1)))
   (win-condition (Black)  (absolute-config Rat (d1)))
   (win-condition (White)  (absolute-config Elephant (d9)))
   (win-condition (White)  (absolute-config Tiger (d9)))
   (win-condition (White)  (absolute-config Lion (d9)))
   (win-condition (White)  (absolute-config Panther (d9)))
   (win-condition (White)  (absolute-config Dog (d9)))
   (win-condition (White)  (absolute-config Wolf (d9)))
   (win-condition (White)  (absolute-config Cat (d9)))
   (win-condition (White)  (absolute-config Rat (d9)))
)

(variant
   (title "Jungle Variant")
   (piece
      (name Elephant)
      (description "象\不可入水，只能被老鼠或象吃。。")
      (help "象：吃老鼠以外的所有")
      (image White "images\Jungle\WElephant.bmp" Black "images\Jungle\BElephant.bmp")
      (moves
         (Elephant-Step2 n)
         (Elephant-Step2 e)
         (Elephant-Step2 s)
         (Elephant-Step2 w)
      )
   )
)